<html>
<header>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<style type="text/css">
<!--
textarea {
  width:100%;
  height:90px;
  overflow:auto;
}

table {
  border: 2px solid #333;
  border-collapse: collapse;
  margin: 0.8em 1.0em;
}

th {
 background: #E1E2E6;
 padding: 3px;
 border: 1px solid #666;
}

td, tr {
  padding: 3px;
  border: 1px solid #666;
}
-->
</style>
<script type="text/javascript">//<![CDATA[
var VIEW_URL = '/djambe/view/';
var IFRAME_VIEW_URL = '/djambe/iframe_view/';
var MEDIA_URL = '/djambe_media/media/';
var IFRAME_ID = 0;

function el(id) {
  return document.getElementById(id);
}

function test_all() {
  var pass_count = 0;
  var fail_count = 0;
  var i = 1;

  while(1) {
    if(i < 10) {
      test_id = '00' + i;
    }
    else if(i < 100) {
      test_id = '0' + i;
    }
    else {
      test_id = i;
    }

    if(!el('test' + test_id)) break;

    el('dest' + test_id).value = wikify(el('src' + test_id).value);
    if(el('view' + test_id)) {
      el('view' + test_id).innerHTML = el('expected' + test_id).value;
    }
    if(el('dest' + test_id).value == el('expected' + test_id).value) {
      el('result' + test_id).innerHTML = '<span style="color:blue">Pass</span>';
      pass_count++;
    }
    else {
      el('result' + test_id).innerHTML = '<span style="color:red">Fail</span>';
      fail_count++;
    }
    i++;
  }
  el('pass_count').innerHTML = pass_count;
  el('fail_count').innerHTML = fail_count;
}
//]]>
</script>
<script language="JavaScript" src="jquery.min.js"></script>
<script language="JavaScript" src="render.js"></script>
</header>
<body onLoad="test_all()">
<span style="color:blue">Pass:<span id="pass_count"></span></span></br>
<span style="color:red">Fail:<span id="fail_count"></span></span>

<div id="test001">
<h1>test001: Plain table</h1>
<h3>Source:</h3>
<textarea id="src001">|aaa|bbb|ccc|ddd|
|eee|fff|ggg|hhh|
|iii|jjj|kkk|lll|
</textarea>
<h3>Expected:</h3>
<textarea id="expected001"><table class="wiki">
<tr class="wiki">
<td class="wiki">aaa</td>
<td class="wiki">bbb</td>
<td class="wiki">ccc</td>
<td class="wiki">ddd</td>
</tr>
<tr class="wiki">
<td class="wiki">eee</td>
<td class="wiki">fff</td>
<td class="wiki">ggg</td>
<td class="wiki">hhh</td>
</tr>
<tr class="wiki">
<td class="wiki">iii</td>
<td class="wiki">jjj</td>
<td class="wiki">kkk</td>
<td class="wiki">lll</td>
</tr>
</table></textarea>
<h3>Returned Value:</h3>
<textarea id="dest001"></textarea>
<h3>HTML View:</h3>
<div id="view001"></div>
<h3>Result:<span id="result001"></span></h3>
</div>

<div id="test002">
<h1>test002: Table with caption</h1>
<h3>Source:</h3>
<textarea id="src002">|Caption|c
|aaa|bbb|ccc|ddd|
|eee|fff|ggg|hhh|
|iii|jjj|kkk|lll|
</textarea>
<h3>Expected:</h3>
<textarea id="expected002"><table class="wiki">
<caption>Caption</caption>
<tr class="wiki">
<td class="wiki">aaa</td>
<td class="wiki">bbb</td>
<td class="wiki">ccc</td>
<td class="wiki">ddd</td>
</tr>
<tr class="wiki">
<td class="wiki">eee</td>
<td class="wiki">fff</td>
<td class="wiki">ggg</td>
<td class="wiki">hhh</td>
</tr>
<tr class="wiki">
<td class="wiki">iii</td>
<td class="wiki">jjj</td>
<td class="wiki">kkk</td>
<td class="wiki">lll</td>
</tr>
</table></textarea>
<h3>Returned Value:</h3>
<textarea id="dest002"></textarea>
<h3>HTML View:</h3>
<div id="view002"></div>
<h3>Result:<span id="result002"></span></h3>
</div>

<div id="test003">
<h1>test001: Table with header row</h1>
<h3>Source:</h3>
<textarea id="src003">|aaa|bbb|ccc|ddd|h
|eee|fff|ggg|hhh|
|iii|jjj|kkk|lll|
</textarea>
<h3>Expected:</h3>
<textarea id="expected003"><table class="wiki">
<tr class="wiki">
<th class="wiki">aaa</th>
<th class="wiki">bbb</th>
<th class="wiki">ccc</th>
<th class="wiki">ddd</th>
</tr>
<tr class="wiki">
<td class="wiki">eee</td>
<td class="wiki">fff</td>
<td class="wiki">ggg</td>
<td class="wiki">hhh</td>
</tr>
<tr class="wiki">
<td class="wiki">iii</td>
<td class="wiki">jjj</td>
<td class="wiki">kkk</td>
<td class="wiki">lll</td>
</tr>
</table></textarea>
<h3>Returned Value:</h3>
<textarea id="dest003"></textarea>
<h3>HTML View:</h3>
<div id="view003"></div>
<h3>Result:<span id="result003"></span></h3>
</div>

<div id="test004">
<h1>test004: Table with header column</h1>
<h3>Source:</h3>
<textarea id="src004">|!aaa|bbb|ccc|ddd|
|!eee|fff|ggg|hhh|
|!iii|jjj|kkk|lll|
</textarea>
<h3>Expected:</h3>
<textarea id="expected004"><table class="wiki">
<tr class="wiki">
<th class="wiki">aaa</th>
<td class="wiki">bbb</td>
<td class="wiki">ccc</td>
<td class="wiki">ddd</td>
</tr>
<tr class="wiki">
<th class="wiki">eee</th>
<td class="wiki">fff</td>
<td class="wiki">ggg</td>
<td class="wiki">hhh</td>
</tr>
<tr class="wiki">
<th class="wiki">iii</th>
<td class="wiki">jjj</td>
<td class="wiki">kkk</td>
<td class="wiki">lll</td>
</tr>
</table></textarea>
<h3>Returned Value:</h3>
<textarea id="dest004"></textarea>
<h3>HTML View:</h3>
<div id="view004"></div>
<h3>Result:<span id="result004"></span></h3>
</div>

<div id="test005">
<h1>test005: Table with header row and column</h1>
<h3>Source:</h3>
<textarea id="src005">|aaa|bbb|ccc|ddd|h
|!eee|fff|ggg|hhh|
|!iii|jjj|kkk|lll|
</textarea>
<h3>Expected:</h3>
<textarea id="expected005"><table class="wiki">
<tr class="wiki">
<th class="wiki">aaa</th>
<th class="wiki">bbb</th>
<th class="wiki">ccc</th>
<th class="wiki">ddd</th>
</tr>
<tr class="wiki">
<th class="wiki">eee</th>
<td class="wiki">fff</td>
<td class="wiki">ggg</td>
<td class="wiki">hhh</td>
</tr>
<tr class="wiki">
<th class="wiki">iii</th>
<td class="wiki">jjj</td>
<td class="wiki">kkk</td>
<td class="wiki">lll</td>
</tr>
</table></textarea>
<h3>Returned Value:</h3>
<textarea id="dest005"></textarea>
<h3>HTML View:</h3>
<div id="view005"></div>
<h3>Result:<span id="result005"></span></h3>
</div>

<div id="test006">
<h1>test006: Table with align</h1>
<h3>Source:</h3>
<textarea id="src006">|aaa|bbbbb|ccccc|ddddd|h
|!eee| right| center |left |
|!iii|jjj|kkk|lll|
</textarea>
<h3>Expected:</h3>
<textarea id="expected006"><table class="wiki">
<tr class="wiki">
<th class="wiki">aaa</th>
<th class="wiki">bbbbb</th>
<th class="wiki">ccccc</th>
<th class="wiki">ddddd</th>
</tr>
<tr class="wiki">
<th class="wiki">eee</th>
<td align="right" class="wiki">right</td>
<td align="center" class="wiki">center</td>
<td class="wiki">left</td>
</tr>
<tr class="wiki">
<th class="wiki">iii</th>
<td class="wiki">jjj</td>
<td class="wiki">kkk</td>
<td class="wiki">lll</td>
</tr>
</table></textarea>
<h3>Returned Value:</h3>
<textarea id="dest006"></textarea>
<h3>HTML View:</h3>
<div id="view006"></div>
<h3>Result:<span id="result006"></span></h3>
</div>

<div id="test007">
<h1>test007: Table with colspan</h1>
<h3>Source:</h3>
<textarea id="src007">|aaa|bbb|ccc|ddd|h
|!eee|>|ggg|hhh|
|!iii|>|>|lll|
</textarea>
<h3>Expected:</h3>
<textarea id="expected007"><table class="wiki">
<tr class="wiki">
<th class="wiki">aaa</th>
<th class="wiki">bbb</th>
<th class="wiki">ccc</th>
<th class="wiki">ddd</th>
</tr>
<tr class="wiki">
<th class="wiki">eee</th>
<td colspan="2" class="wiki">ggg</td>
<td class="wiki">hhh</td>
</tr>
<tr class="wiki">
<th class="wiki">iii</th>
<td colspan="3" class="wiki">lll</td>
</tr>
</table></textarea>
<h3>Returned Value:</h3>
<textarea id="dest007"></textarea>
<h3>HTML View:</h3>
<div id="view007"></div>
<h3>Result:<span id="result007"></span></h3>
</div>

<div id="test008">
<h1>test008: Table with rowspan</h1>
<h3>Source:</h3>
<textarea id="src008">|aaa|bbb|ccc|ddd|h
|!eee|fff|ggg|hhh|
|!iii|~|~|lll|
|!mmm|nnn|~|ppp|
</textarea>
<h3>Expected:</h3>
<textarea id="expected008"><table class="wiki">
<tr class="wiki">
<th class="wiki">aaa</th>
<th class="wiki">bbb</th>
<th class="wiki">ccc</th>
<th class="wiki">ddd</th>
</tr>
<tr class="wiki">
<th class="wiki">eee</th>
<td rowspan="2" class="wiki">fff</td>
<td rowspan="3" class="wiki">ggg</td>
<td class="wiki">hhh</td>
</tr>
<tr class="wiki">
<th class="wiki">iii</th>
<td class="wiki">lll</td>
</tr>
<tr class="wiki">
<th class="wiki">mmm</th>
<td class="wiki">nnn</td>
<td class="wiki">ppp</td>
</tr>
</table></textarea>
<h3>Returned Value:</h3>
<textarea id="dest008"></textarea>
<h3>HTML View:</h3>
<div id="view008"></div>
<h3>Result:<span id="result008"></span></h3>

<div id="test009">
<h1>test009: Table with colspan and rowspan</h1>
<h3>Source:</h3>
<textarea id="src009">|col1|col2|col3|h
|item1|>|item2|
|item3|item4|item5|
|~|~|item6|
|~|item7|item8|
</textarea>
<h3>Expected:</h3>
<textarea id="expected009"><table class="wiki">
<tr class="wiki">
<th class="wiki">col1</th>
<th class="wiki">col2</th>
<th class="wiki">col3</th>
</tr>
<tr class="wiki">
<td class="wiki">item1</td>
<td colspan="2" class="wiki">item2</td>
</tr>
<tr class="wiki">
<td rowspan="3" class="wiki">item3</td>
<td rowspan="2" class="wiki">item4</td>
<td class="wiki">item5</td>
</tr>
<tr class="wiki">
<td class="wiki">item6</td>
</tr>
<tr class="wiki">
<td class="wiki">item7</td>
<td class="wiki">item8</td>
</tr>
</table></textarea>
<h3>Returned Value:</h3>
<textarea id="dest009"></textarea>
<h3>HTML View:</h3>
<div id="view009"></div>
<h3>Result:<span id="result009"></span></h3>

<div id="test010">
<h1>test010: Table with header row</h1>
<h3>Source:</h3>
<textarea id="src010">|aaa|bbb|ccc|ddd|h
|eee|fff|ggg|hhh|
|iii|jjj|kkk|lll|
</textarea>
<h3>Expected:</h3>
<textarea id="expected010"><table class="wiki">
<tr class="wiki">
<th class="wiki">aaa</th>
<th class="wiki">bbb</th>
<th class="wiki">ccc</th>
<th class="wiki">ddd</th>
</tr>
<tr class="wiki">
<td class="wiki">eee</td>
<td class="wiki">fff</td>
<td class="wiki">ggg</td>
<td class="wiki">hhh</td>
</tr>
<tr class="wiki">
<td class="wiki">iii</td>
<td class="wiki">jjj</td>
<td class="wiki">kkk</td>
<td class="wiki">lll</td>
</tr>
</table></textarea>
<h3>Returned Value:</h3>
<textarea id="dest010"></textarea>
<h3>HTML View:</h3>
<div id="view010"></div>
<h3>Result:<span id="result010"></span></h3>
</div>

<div id="test011">
<h1>test010: Decoration in cells</h1>
<h3>Source:</h3>
<textarea id="src011">|aaa|bbb|ccc|ddd|h
|==eee==|''fff''|%%ggg%%|hhh|
|iii|jjj|kkk|__lll__|
</textarea>
<h3>Expected:</h3>
<textarea id="expected011"><table class="wiki">
<tr class="wiki">
<th class="wiki">aaa</th>
<th class="wiki">bbb</th>
<th class="wiki">ccc</th>
<th class="wiki">ddd</th>
</tr>
<tr class="wiki">
<td class="wiki"><span style="text-decoration:line-through">eee</span></td>
<td class="wiki"><span style="font-weight:bold">fff</span></td>
<td class="wiki"><span style="font-style:italic">ggg</span></td>
<td class="wiki">hhh</td>
</tr>
<tr class="wiki">
<td class="wiki">iii</td>
<td class="wiki">jjj</td>
<td class="wiki">kkk</td>
<td class="wiki"><span style="text-decoration:underline">lll</span></td>
</tr>
</table></textarea>
<h3>Returned Value:</h3>
<textarea id="dest011"></textarea>
<h3>HTML View:</h3>
<div id="view011"></div>
<h3>Result:<span id="result011"></span></h3>

</body>
</html>